<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>10-4 阻止元素默认行为</title>
</head>

<body>
  <a class='link' href="http://baidu.com">Click To Baidu</a>

  <script>
    let link = document.querySelector(".link");

    link.onclick = function (ev) {
      ev.preventDefault() || (ev.returnBubble = true)
    }
  </script>
</body>

</html>